import time
import threading
def method_test1(num):
    for i in range(num):
        print(f'method_test1{i}')
        time.sleep(0.5)


def method_test2(num):
    for i in range(num):
        print(f'method_test2:{i}')
        time.sleep(0.5)


if __name__ == '__main__':
    # method_test1(5)
    # method_test2(5)

    # 下边这个代码代表的是 将one 和 two 设置为守护主线程  如果主线程结束了那么 one和two也就跟着主线程结束了
    # one = threading.Thread(target= method_test1,args= (5,),daemon=True)
    # two = threading.Thread(target= method_test2,kwargs={"num":5},daemon=True)


    one = threading.Thread(target=method_test1, args=(5,))
    two = threading.Thread(target=method_test2, kwargs={"num": 5})
    two.daemon = True
    one.daemon = True
    one.start()
    two.start()
    print("主线程执行完毕！")
